package com.mapler.ui;

import com.mapler.model.AdModel;
import com.mapler.model.SModel;
import com.mapler.model.UAModel;
import com.mapler.service.INotifier;
import com.mapler.service.JobWorker;
import com.mapler.service.W4MWorker;
import com.mapler.utility.HttpHelper;
import com.mapler.utility.IConstant;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import javax.swing.SwingUtilities;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Node;

/**
 *
 * @author none
 */
public class EngineCUI extends javax.swing.JPanel implements INotifier {

    public ScheduledExecutorService emailExecutor = Executors.newScheduledThreadPool(10);
    protected ScheduledFuture<?> emailFuture = null;
    private String username;
    private String password;
    private String country;
    private SModel sModel;
    private ArrayList<UAModel> uaModels;
    private ArrayList<AdModel> addModels;
    private HashMap<String, UAModel> usHashMap;
    private static Logger log = Logger.getLogger(EngineCUI.class);
    private INotifier iNotifier;
    private HashMap<Integer,ArrayList<AdModel>> addMap = new HashMap();
            
    public EngineCUI(String username, String password, String country) {
        this.username = username;
        this.password = password;
        this.country = country;
        initComponents();
        this.vpn.setSelected(true);
        initSettings();
    }

    public SModel getsModel() {
        if (sModel == null) {
            sModel = new SModel();
        }
        return sModel;
    }

    public void setsModel(SModel sModel) {
        this.sModel = sModel;
    }

    public ArrayList<UAModel> getUaModels() {
        if (uaModels == null) {
            uaModels = new ArrayList<UAModel>();
        }
        return uaModels;
    }

    public void setUaModels(ArrayList<UAModel> uaModels) {
        this.uaModels = uaModels;
    }

    public ArrayList<AdModel> getAddModels() {
        if (addModels == null) {
            addModels = new ArrayList<AdModel>();
        }
        return addModels;
    }

    public void setAddModels(ArrayList<AdModel> addModels) {
        this.addModels = addModels;
    }

    public HashMap<String, UAModel> getUsHashMap() {
        if (usHashMap == null) {
            usHashMap = new HashMap<String, UAModel>();
        }
        return usHashMap;
    }

    public void setUsHashMap(HashMap<String, UAModel> usHashMap) {
        this.usHashMap = usHashMap;
    }

    public HashMap<Integer, ArrayList<AdModel>> getAddMap() {
        return addMap;
    }

    public void setAddMap(HashMap<Integer, ArrayList<AdModel>> addMap) {
        this.addMap = addMap;
    }  
    
    /**
     * Creates new form EngineUI
     */
    public EngineCUI() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel4 = new javax.swing.JLabel();
        start = new javax.swing.JButton();
        end = new javax.swing.JButton();
        cont = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        type = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        driver = new javax.swing.JComboBox();
        accountID = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        vpn = new javax.swing.JCheckBox();
        message = new javax.swing.JLabel();
        jCBWebEmail = new javax.swing.JCheckBox();
        jBStop = new javax.swing.JButton();
        jCBCloseBrowser = new javax.swing.JCheckBox();
        jCBRandom = new javax.swing.JCheckBox();
        jCBDeletePost = new javax.swing.JCheckBox();
        jCBUseProxy = new javax.swing.JCheckBox();
        jCBProxyType = new javax.swing.JCheckBox();
        jCBUpdateAccount = new javax.swing.JCheckBox();
        jCBPostInSameSession = new javax.swing.JCheckBox();
        jTFRenew = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jCBHideResources = new javax.swing.JCheckBox();
        jCBUseSlot = new javax.swing.JCheckBox();
        jTFSlotNo = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();

        jLabel4.setText("jLabel4");

        start.setText("Start");
        start.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                startActionPerformed(evt);
            }
        });

        end.setText("Stop & Exit");
        end.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                endActionPerformed(evt);
            }
        });

        cont.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "US", "UK" }));

        jLabel1.setText("Country");

        type.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "JOB", "W4M" }));

        jLabel2.setText("Type");

        jLabel3.setText("Browser");

        driver.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "FF", "IE", "GC" }));

        jLabel5.setText("Account ID");

        vpn.setText("VPN");

        jCBWebEmail.setText("Web email");

        jBStop.setText("Stop");
        jBStop.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBStopActionPerformed(evt);
            }
        });

        jCBCloseBrowser.setText("Close browser");

        jCBRandom.setText("Random");

        jCBDeletePost.setText("Delete post");

        jCBUseProxy.setText("Use Proxy");

        jCBProxyType.setSelected(true);
        jCBProxyType.setText("Proxy Type (Default Manual)");

        jCBUpdateAccount.setText("Update Account");

        jCBPostInSameSession.setText("Post in same session");

        jTFRenew.setToolTipText("");

        jLabel6.setText("ReNew no of items");

        jCBHideResources.setText("Hide resources");

        jCBUseSlot.setText("Use slot");

        jLabel7.setText("Slot no");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(message, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addGap(169, 169, 169)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel3)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2)
                    .addComponent(jLabel5)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jCBHideResources)
                    .addComponent(jCBWebEmail)
                    .addComponent(jCBCloseBrowser)
                    .addComponent(jCBPostInSameSession)
                    .addComponent(jCBRandom)
                    .addComponent(jCBUpdateAccount)
                    .addComponent(jCBProxyType)
                    .addComponent(jCBDeletePost)
                    .addComponent(jCBUseProxy)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(start)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jBStop)
                        .addGap(14, 14, 14)
                        .addComponent(end))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jTFRenew, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(accountID, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(driver, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(type, javax.swing.GroupLayout.Alignment.LEADING, 0, 97, Short.MAX_VALUE)
                            .addComponent(cont, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(30, 30, 30)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel7)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTFSlotNo, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jCBUseSlot)))
                    .addComponent(vpn))
                .addContainerGap(101, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(message, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(25, 25, 25)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cont, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1)
                    .addComponent(jCBUseSlot))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(type, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2)
                    .addComponent(jTFSlotNo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(driver, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(accountID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addGap(5, 5, 5)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTFRenew, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jCBPostInSameSession)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(vpn)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jCBWebEmail)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jCBCloseBrowser)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jCBRandom)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jCBDeletePost)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jCBUseProxy, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jCBProxyType)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jCBUpdateAccount)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jCBHideResources)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(start)
                    .addComponent(end)
                    .addComponent(jBStop))
                .addGap(20, 20, 20))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void startActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startActionPerformed
        if (this.getsModel() == null) {
            notify("Setting is empty");
            return;
        }

        if (this.getUaModels() == null || this.getUaModels().isEmpty()) {
            notify("CL account is empty");
            return;
        }

        if (this.getAddModels() == null || this.getAddModels().isEmpty()) {
            notify("CL AD is empty");
            return;
        }

        this.getsModel().setDriver(this.driver.getSelectedItem().toString());
        this.getsModel().setAccountID(accountID.getText());
        this.getsModel().setIsVPN(vpn.isSelected());
        this.getsModel().setWebMail(jCBWebEmail.isSelected());
        this.getsModel().setStopEngine(false);
        this.getsModel().setCloseBrowser(jCBCloseBrowser.isSelected());
        this.getsModel().setRandom(jCBRandom.isSelected());
        this.getsModel().setDeletePost(jCBDeletePost.isSelected());
        this.getsModel().setUpdateAccount(jCBUpdateAccount.isSelected());
        sModel.setProxyType(jCBProxyType.isSelected());
        sModel.setBrowserProxy(jCBUseProxy.isSelected());
        sModel.setUseSlot(jCBUseSlot.isSelected());
        sModel.setUsername(username);
        sModel.setPassword(password);
        sModel.setCountry(country);        
        sModel.setPostInSession(jCBPostInSameSession.isSelected());
        sModel.setRenewItems(jTFRenew.getText());
        sModel.setResourcesHide(jCBHideResources.isSelected());
        
        if(StringUtils.isNotBlank(jTFSlotNo.getText()) ){
            sModel.setSlotNo(Integer.parseInt(jTFSlotNo.getText()));
        }
        if (type.getSelectedItem().toString().equalsIgnoreCase("JOB")) {
            JobWorker jobWorker = new JobWorker(this.getiNotifier(), this.getsModel(), this.getUaModels(),
                    this.getAddModels(), this.getUsHashMap());
            jobWorker.update();
        } else if (type.getSelectedItem().toString().equalsIgnoreCase("W4M")) {
            W4MWorker w4MWorker = new W4MWorker(this.getiNotifier(), this.getsModel(), this.getUaModels(),
                    this.getAddModels(), this.getUsHashMap());
            w4MWorker.setAddMap(this.getAddMap());
            w4MWorker.update();
        }

        /*if (!checkEmail.isSelected()) {
         if (emailFuture != null && !emailFuture.isCancelled() && !emailExecutor.isShutdown()) {
         return;
         }
         MailRunner mailRunner = new MailRunner(iNotifier, sModel);
         emailFuture = emailExecutor.scheduleAtFixedRate(mailRunner, 1, 3, TimeUnit.MINUTES);
         }*/
    }//GEN-LAST:event_startActionPerformed

    private void endActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_endActionPerformed
        try {
            String uri = "http://" + IConstant.HOSTNAME + "/index.php?r=userAccount/logout&username=" + this.username + "&password=" + this.password;
            String response = HttpHelper.post(new URL(uri), "");

            Document document = DocumentHelper.parseText(response);
            String errorCode = document.valueOf("Response/errorcode");
            if (errorCode.equalsIgnoreCase("000")) {
                String msg = document.valueOf("Response/message");
                log.debug("Problem in logout. causes " + msg);
            } else {
                log.debug("Signout perfectly ");
            }
            Runtime.getRuntime().exec("taskkill /F /IM java.exe");
            Runtime.getRuntime().exec("taskkill /F /IM iRobot.exe");
            Runtime.getRuntime().exec("taskkill /F /IM javaw.exe");
        } catch (Throwable ex) {
            log.debug("Error " + ex);
        }
    }//GEN-LAST:event_endActionPerformed

    private void jBStopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBStopActionPerformed
        this.getsModel().setStopEngine(true);
    }//GEN-LAST:event_jBStopActionPerformed

    public void initSettings() {
        this.setsModel(null);
        this.setUaModels(null);
        this.setAddModels(null);
        this.setUsHashMap(null);
        this.fillSetting(this.getsModel());
        this.fillUserAccount(this.getUaModels());
        this.fillAdd(this.getAddModels());
    }

    private void fillAdd(ArrayList<AdModel> addModels) {
        try {
            String uri = "http://" + IConstant.HOSTNAME + "/index.php?r=advertisement/getAdvertisement&username="
                    + this.username + "&password=" + this.password;
            String response = HttpHelper.post(new URL(uri), "");
            Document document = DocumentHelper.parseText(response);
            String errorCode = document.valueOf("Response/errorcode");
            if (!errorCode.equalsIgnoreCase("000")) {
                List<Node> list = document.selectNodes("/Response/accounts/account");
                for (Node node : list) {
                    AdModel model = new AdModel();
                    model.setId(node.valueOf("id"));
                    model.setDescription(node.valueOf("description"));
                    model.setTitle(node.valueOf("title"));
                    model.setRemarks(node.valueOf("remarks"));
                    model.setCompensation(node.valueOf("compensation"));
                    model.setAge(node.valueOf("age"));
                    model.setBody(node.valueOf("body"));
                    model.setHeight(node.valueOf("height"));
                    model.setStatus(node.valueOf("status"));
                    model.setLikes(node.valueOf("likes"));
                    
                    if(node.valueOf("slot")!= null && !this.getAddMap().containsKey(Integer.valueOf(node.valueOf("slot")))){
                        this.getAddMap().put(Integer.valueOf(node.valueOf("slot")), new ArrayList<AdModel>());
                    }
                    this.getAddMap().get(Integer.valueOf(node.valueOf("slot"))).add(model);
                    addModels.add(model);
                }
            }
        } catch (Throwable ex) {
            ex.printStackTrace();
        }
    }

    private void fillUserAccount(ArrayList<UAModel> uaModels) {
        try {
            String uri = "http://" + IConstant.HOSTNAME + "/index.php?r=account/getAccounts&username="
                    + this.username + "&password=" + this.password + "&working=1";
            String response = HttpHelper.post(new URL(uri), "");
            Document document = DocumentHelper.parseText(response);
            String errorCode = document.valueOf("Response/errorcode");
            if (!errorCode.equalsIgnoreCase("000")) {
                List<Node> list = document.selectNodes("/Response/accounts/account");
                for (Node node : list) {
                    UAModel model = new UAModel();
                    model.setId(node.valueOf("id"));
                    model.setEmail(node.valueOf("email"));
                    model.setEmailPassword(node.valueOf("email_pass"));
                    model.setClientPassword(node.valueOf("cl_pass"));
                    model.setForwardEmail(node.valueOf("fw_email"));
                    model.setForwardEmailPass(node.valueOf("fw_email_pass"));
                    model.setPhone(node.valueOf("phone"));
                    model.setState(node.valueOf("state"));
                    model.setLink(node.valueOf("link"));
                    model.setProxy(node.valueOf("proxy"));
                    model.setRemarks(node.valueOf("remarks"));
                    model.setProxyIp(node.valueOf("proxy_ip"));
                    model.setProxyPort(Integer.parseInt(node.valueOf("proxy_port")));
                    model.setProxyUsername(node.valueOf("proxy_username"));
                    model.setProxyPassword(node.valueOf("proxy_password"));
                    uaModels.add(model);
                    this.getUsHashMap().put(node.valueOf("id"), model);
                }
            }
        } catch (Throwable ex) {
            ex.printStackTrace();
        }
    }

    private void fillSetting(SModel sModel) {
        try {
            String uri = "http://" + IConstant.HOSTNAME + "/index.php?r=setting/getSetting&username="
                    + this.username + "&password=" + this.password;
            String response = HttpHelper.post(new URL(uri), "");
            if (response.isEmpty()) {
                return;
            }
            Document document = DocumentHelper.parseText(response);
            String errorCode = document.valueOf("Response/errorcode");
            if (!errorCode.equalsIgnoreCase("000")) {
                sModel.setRecordId(document.valueOf("/Response/setting/id"));
                sModel.setPostPerIP(document.valueOf("/Response/setting/post_per_ip"));
                sModel.setPostInterval(document.valueOf("/Response/setting/post_interval"));
                sModel.setUpage(document.valueOf("/Response/setting/upper_age"));
                sModel.setLwage(document.valueOf("/Response/setting/lower_age"));
                sModel.setLogincl(document.valueOf("/Response/setting/login_cl"));
                sModel.setUseLocation(document.valueOf("/Response/setting/use_location"));
                sModel.setRandomSubarea(document.valueOf("/Response/setting/random_subarea"));
                sModel.setUseAge(document.valueOf("/Response/setting/use_age"));
                sModel.setMaxWaitTime(document.valueOf("/Response/setting/max_wait_time"));
                sModel.setUseFWlink(document.valueOf("/Response/setting/use_fw_email"));

                sModel.setLogAutoScroll(document.valueOf("/Response/setting/log_auto_scroll"));
                sModel.setAutoPost(document.valueOf("/Response/setting/auto_post"));
                sModel.setChangeIP(document.valueOf("/Response/setting/change_ip"));
                sModel.setName(document.valueOf("/Response/setting/user_name"));
                sModel.setPass(document.valueOf("/Response/setting/upass"));
                sModel.setUseProxy(document.valueOf("/Response/setting/use_proxy"));
                sModel.setMaxTry(document.valueOf("/Response/setting/max_try"));
                sModel.setVpnName(document.valueOf("/Response/setting/vpn_name"));
                //this.countryUI.setText(document.valueOf("/Response/setting/country_id"));

                sModel.setPostfix(document.valueOf("/Response/setting/postfix"));
                sModel.setPrefix(document.valueOf("/Response/setting/prefix"));
                sModel.setIePath(document.valueOf("/Response/setting/ie_path"));
                sModel.setFfPath(document.valueOf("/Response/setting/ff_path"));
                sModel.setGcPath(document.valueOf("/Response/setting/gc_path"));
            }
        } catch (Throwable ex) {
            ex.printStackTrace();
        }
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField accountID;
    private javax.swing.JComboBox cont;
    private javax.swing.JComboBox driver;
    private javax.swing.JButton end;
    private javax.swing.JButton jBStop;
    private javax.swing.JCheckBox jCBCloseBrowser;
    private javax.swing.JCheckBox jCBDeletePost;
    private javax.swing.JCheckBox jCBHideResources;
    private javax.swing.JCheckBox jCBPostInSameSession;
    private javax.swing.JCheckBox jCBProxyType;
    private javax.swing.JCheckBox jCBRandom;
    private javax.swing.JCheckBox jCBUpdateAccount;
    private javax.swing.JCheckBox jCBUseProxy;
    private javax.swing.JCheckBox jCBUseSlot;
    private javax.swing.JCheckBox jCBWebEmail;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JTextField jTFRenew;
    private javax.swing.JTextField jTFSlotNo;
    private javax.swing.JLabel message;
    private javax.swing.JButton start;
    private javax.swing.JComboBox type;
    private javax.swing.JCheckBox vpn;
    // End of variables declaration//GEN-END:variables

    @Override
    public void notify(final String info) {
        try {
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    message.setText(info);
                }
            });
        } catch (Throwable ex) {
            log.debug("notify:: Error causes " + ex.getMessage());
        }
    }

    public INotifier getiNotifier() {
        if (iNotifier == null) {
            iNotifier = this;
        }
        return iNotifier;
    }

    public void setiNotifier(INotifier iNotifier) {
        this.iNotifier = iNotifier;
    }

    @Override
    public void write(String info) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
